#include "FireEntity.h"




FireEntity::FireEntity(int id, int type, double x, double y, Rect* bridgeRect)
{
	_data = new FireData(id, type, x, y);
	//_data->getRect()->Y -= _data->getRect()->Height/2;

	_nextX = _data->getRect()->X;
	_x0 = _data->getRect()->X;
	_data->getRect()->Vx = FIRE_V;
	_movingRight = bridgeRect->getRight();
	_movingLeft = bridgeRect->getLeft();
}

void FireEntity::update(long time)
{
	_nextX += _data->getRect()->Vx;
	if(_nextX >= (_movingRight - _data->getRect()->Width/2) || _nextX <= (_movingLeft + _data->getRect()->Width/2))
	{
		_data->getRect()->Vx *= (-1);
	}

	_data->getRect()->X += _data->getRect()->Vx;
	_data->sprites->updateCurrent();
}

void FireEntity::draw(long time)
{
	_data->sprites->draw();
}

AbstractData* FireEntity::getAbstractData()
{
	return _data;
}

void FireEntity::swapV()
{
	_data->getRect()->Vx *= -1;
}
